{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "# packages in environment at C:\\Users\\masaikk\\anaconda3\\envs\\skl4:\n",
      "#\n",
      "# Name                    Version                   Build  Channel\n",
      "argon2-cffi               20.1.0           py37h2bbff1b_1    defaults\n",
      "async_generator           1.10             py37h28b3542_0    defaults\n",
      "attrs                     21.2.0             pyhd3eb1b0_0    defaults\n",
      "backcall                  0.2.0              pyhd3eb1b0_0    defaults\n",
      "blas                      1.0                         mkl    defaults\n",
      "bleach                    3.3.0              pyhd3eb1b0_0    defaults\n",
      "boto3                     1.17.88            pyhd3eb1b0_0    defaults\n",
      "botocore                  1.20.94            pyhd3eb1b0_1    defaults\n",
      "brotlipy                  0.7.0           py37h2bbff1b_1003    defaults\n",
      "ca-certificates           2021.5.25            haa95532_1    defaults\n",
      "certifi                   2021.5.30        py37haa95532_0    defaults\n",
      "cffi                      1.14.5           py37hcd4344a_0    defaults\n",
      "colorama                  0.4.4              pyhd3eb1b0_0    defaults\n",
      "cryptography              3.4.7            py37h71e12ea_0    defaults\n",
      "decorator                 5.0.9              pyhd3eb1b0_0    defaults\n",
      "defusedxml                0.7.1              pyhd3eb1b0_0    defaults\n",
      "entrypoints               0.3                      py37_0    defaults\n",
      "icc_rt                    2019.0.0             h0cc432a_1    defaults\n",
      "icu                       58.2                 ha925a31_3    defaults\n",
      "idna                      3.2                pyhd3eb1b0_0    defaults\n",
      "importlib-metadata        3.10.0           py37haa95532_0    defaults\n",
      "importlib_metadata        3.10.0               hd3eb1b0_0    defaults\n",
      "intel-openmp              2021.2.0           haa95532_616    defaults\n",
      "ipykernel                 5.3.4            py37h5ca1d4c_0    defaults\n",
      "ipython                   7.22.0           py37hd4e2768_0    defaults\n",
      "ipython_genutils          0.2.0              pyhd3eb1b0_1    defaults\n",
      "ipywidgets                7.6.3              pyhd3eb1b0_1    defaults\n",
      "jedi                      0.17.0                   py37_0    defaults\n",
      "jinja2                    3.0.0              pyhd3eb1b0_0    defaults\n",
      "jmespath                  0.10.0                     py_0    defaults\n",
      "joblib                    1.0.1              pyhd3eb1b0_0    defaults\n",
      "jpeg                      9b                   hb83a4c4_2    defaults\n",
      "jsonschema                3.2.0                      py_2    defaults\n",
      "jupyter                   1.0.0                    py37_7    defaults\n",
      "jupyter_client            6.1.12             pyhd3eb1b0_0    defaults\n",
      "jupyter_console           6.4.0              pyhd3eb1b0_0    defaults\n",
      "jupyter_core              4.7.1            py37haa95532_0    defaults\n",
      "jupyterlab_pygments       0.1.2                      py_0    defaults\n",
      "jupyterlab_widgets        1.0.0              pyhd3eb1b0_1    defaults\n",
      "libpng                    1.6.37               h2a8f88b_0    defaults\n",
      "libsodium                 1.0.18               h62dcd97_0    defaults\n",
      "m2w64-gcc-libgfortran     5.3.0                         6    defaults\n",
      "m2w64-gcc-libs            5.3.0                         7    defaults\n",
      "m2w64-gcc-libs-core       5.3.0                         7    defaults\n",
      "m2w64-gmp                 6.1.0                         2    defaults\n",
      "m2w64-libwinpthread-git   5.0.0.4634.697f757               2    defaults\n",
      "markupsafe                2.0.1            py37h2bbff1b_0    defaults\n",
      "mistune                   0.8.4           py37hfa6e2cd_1001    defaults\n",
      "mkl                       2021.2.0           haa95532_296    defaults\n",
      "mkl-service               2.3.0            py37h2bbff1b_1    defaults\n",
      "mkl_fft                   1.3.0            py37h277e83a_2    defaults\n",
      "mkl_random                1.2.1            py37hf11a4ad_2    defaults\n",
      "msys2-conda-epoch         20160418                      1    defaults\n",
      "nbclient                  0.5.3              pyhd3eb1b0_0    defaults\n",
      "nbconvert                 6.1.0            py37haa95532_0    defaults\n",
      "nbformat                  5.1.3              pyhd3eb1b0_0    defaults\n",
      "nest-asyncio              1.5.1              pyhd3eb1b0_0    defaults\n",
      "notebook                  6.4.0            py37haa95532_0    defaults\n",
      "numpy                     1.20.2           py37ha4e8547_0    defaults\n",
      "numpy-base                1.20.2           py37hc2deb75_0    defaults\n",
      "openssl                   1.1.1k               h2bbff1b_0    defaults\n",
      "packaging                 20.9               pyhd3eb1b0_0    defaults\n",
      "pandocfilters             1.4.3            py37haa95532_1    defaults\n",
      "parso                     0.8.2              pyhd3eb1b0_0    defaults\n",
      "pickleshare               0.7.5           pyhd3eb1b0_1003    defaults\n",
      "pip                       21.1.2           py37haa95532_0    defaults\n",
      "prometheus_client         0.11.0             pyhd3eb1b0_0    defaults\n",
      "prompt-toolkit            3.0.17             pyh06a4308_0    defaults\n",
      "prompt_toolkit            3.0.17               hd3eb1b0_0    defaults\n",
      "pycparser                 2.20                       py_2    defaults\n",
      "pygments                  2.9.0              pyhd3eb1b0_0    defaults\n",
      "pyopenssl                 20.0.1             pyhd3eb1b0_1    defaults\n",
      "pyparsing                 2.4.7              pyhd3eb1b0_0    defaults\n",
      "pyqt                      5.9.2            py37h6538335_2    defaults\n",
      "pyrsistent                0.17.3           py37he774522_0    defaults\n",
      "pysocks                   1.7.1                    py37_1    defaults\n",
      "python                    3.7.10               h6244533_0    defaults\n",
      "python-dateutil           2.8.1              pyhd3eb1b0_0    defaults\n",
      "pywin32                   227              py37he774522_1    defaults\n",
      "pywinpty                  0.5.7                    py37_0    defaults\n",
      "pyzmq                     20.0.0           py37hd77b12b_1    defaults\n",
      "qt                        5.9.7            vc14h73c81de_0    defaults\n",
      "qtconsole                 5.1.0              pyhd3eb1b0_0    defaults\n",
      "qtpy                      1.9.0                      py_0    defaults\n",
      "s3transfer                0.4.2              pyhd3eb1b0_0    defaults\n",
      "scikit-learn              0.24.2           py37hf11a4ad_1    defaults\n",
      "scipy                     1.6.2            py37h66253e8_1    defaults\n",
      "send2trash                1.5.0              pyhd3eb1b0_1    defaults\n",
      "setuptools                52.0.0           py37haa95532_0    defaults\n",
      "sip                       4.19.8           py37h6538335_0    defaults\n",
      "six                       1.16.0             pyhd3eb1b0_0    defaults\n",
      "sqlite                    3.35.4               h2bbff1b_0    defaults\n",
      "terminado                 0.9.4            py37haa95532_0    defaults\n",
      "testpath                  0.4.4              pyhd3eb1b0_0    defaults\n",
      "threadpoolctl             2.1.0              pyh5ca1d4c_0    defaults\n",
      "tornado                   6.1              py37h2bbff1b_0    defaults\n",
      "traitlets                 5.0.5              pyhd3eb1b0_0    defaults\n",
      "typing_extensions         3.7.4.3            pyha847dfd_0    defaults\n",
      "urllib3                   1.26.4             pyhd3eb1b0_0    defaults\n",
      "vc                        14.2                 h21ff451_1    defaults\n",
      "vs2015_runtime            14.27.29016          h5e58377_2    defaults\n",
      "wcwidth                   0.2.5                      py_0    defaults\n",
      "webencodings              0.5.1                    py37_1    defaults\n",
      "wheel                     0.36.2             pyhd3eb1b0_0    defaults\n",
      "widgetsnbextension        3.5.1                    py37_0    defaults\n",
      "win_inet_pton             1.1.0            py37haa95532_0    defaults\n",
      "wincertstore              0.2                      py37_0    defaults\n",
      "winpty                    0.4.3                         4    defaults\n",
      "zeromq                    4.3.3                ha925a31_3    defaults\n",
      "zipp                      3.4.1              pyhd3eb1b0_0    defaults\n",
      "zlib                      1.2.11               h62dcd97_4    defaults\n"
     ]
    }
   ],
   "source": [
    "!conda list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.datasets import load_boston\n",
    "import pandas as pd"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['CRIM' 'ZN' 'INDUS' 'CHAS' 'NOX' 'RM' 'AGE' 'DIS' 'RAD' 'TAX' 'PTRATIO'\n",
      " 'B' 'LSTAT']\n"
     ]
    }
   ],
   "source": [
    "dataset = load_boston()\n",
    "print(dataset.get('feature_names'))\n",
    "# 使用第6-8列feature，即AGE(1940年以前建成的自住单位的比例),\n",
    "# DIS(距离五个波士顿就业中心的加权距离),RAD(距离高速公路的便利指数)\n",
    "X = dataset.data[:, 5:8]\n",
    "y = dataset.target\n",
    "\n",
    "# 划分训练集和测试集\n",
    "X_train = X[:-20]\n",
    "X_test = X[-20:]\n",
    "y_train = y[:-20]\n",
    "y_test = y[-20:]\n",
    "\n",
    "regr = LinearRegression()\n",
    "regr.fit(X_train, y_train)\n",
    "y_test_pred = regr.predict(X_test)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "array([24. , 21.6, 34.7, 33.4, 36.2, 28.7, 22.9, 27.1, 16.5, 18.9, 15. ,\n       18.9, 21.7, 20.4, 18.2, 19.9, 23.1, 17.5, 20.2, 18.2, 13.6, 19.6,\n       15.2, 14.5, 15.6, 13.9, 16.6, 14.8, 18.4, 21. , 12.7, 14.5, 13.2,\n       13.1, 13.5, 18.9, 20. , 21. , 24.7, 30.8, 34.9, 26.6, 25.3, 24.7,\n       21.2, 19.3, 20. , 16.6, 14.4, 19.4, 19.7, 20.5, 25. , 23.4, 18.9,\n       35.4, 24.7, 31.6, 23.3, 19.6, 18.7, 16. , 22.2, 25. , 33. , 23.5,\n       19.4, 22. , 17.4, 20.9, 24.2, 21.7, 22.8, 23.4, 24.1, 21.4, 20. ,\n       20.8, 21.2, 20.3, 28. , 23.9, 24.8, 22.9, 23.9, 26.6, 22.5, 22.2,\n       23.6, 28.7, 22.6, 22. , 22.9, 25. , 20.6, 28.4, 21.4, 38.7, 43.8,\n       33.2, 27.5, 26.5, 18.6, 19.3, 20.1, 19.5, 19.5, 20.4, 19.8, 19.4,\n       21.7, 22.8, 18.8, 18.7, 18.5, 18.3, 21.2, 19.2, 20.4, 19.3, 22. ,\n       20.3, 20.5, 17.3, 18.8, 21.4, 15.7, 16.2, 18. , 14.3, 19.2, 19.6,\n       23. , 18.4, 15.6, 18.1, 17.4, 17.1, 13.3, 17.8, 14. , 14.4, 13.4,\n       15.6, 11.8, 13.8, 15.6, 14.6, 17.8, 15.4, 21.5, 19.6, 15.3, 19.4,\n       17. , 15.6, 13.1, 41.3, 24.3, 23.3, 27. , 50. , 50. , 50. , 22.7,\n       25. , 50. , 23.8, 23.8, 22.3, 17.4, 19.1, 23.1, 23.6, 22.6, 29.4,\n       23.2, 24.6, 29.9, 37.2, 39.8, 36.2, 37.9, 32.5, 26.4, 29.6, 50. ,\n       32. , 29.8, 34.9, 37. , 30.5, 36.4, 31.1, 29.1, 50. , 33.3, 30.3,\n       34.6, 34.9, 32.9, 24.1, 42.3, 48.5, 50. , 22.6, 24.4, 22.5, 24.4,\n       20. , 21.7, 19.3, 22.4, 28.1, 23.7, 25. , 23.3, 28.7, 21.5, 23. ,\n       26.7, 21.7, 27.5, 30.1, 44.8, 50. , 37.6, 31.6, 46.7, 31.5, 24.3,\n       31.7, 41.7, 48.3, 29. , 24. , 25.1, 31.5, 23.7, 23.3, 22. , 20.1,\n       22.2, 23.7, 17.6, 18.5, 24.3, 20.5, 24.5, 26.2, 24.4, 24.8, 29.6,\n       42.8, 21.9, 20.9, 44. , 50. , 36. , 30.1, 33.8, 43.1, 48.8, 31. ,\n       36.5, 22.8, 30.7, 50. , 43.5, 20.7, 21.1, 25.2, 24.4, 35.2, 32.4,\n       32. , 33.2, 33.1, 29.1, 35.1, 45.4, 35.4, 46. , 50. , 32.2, 22. ,\n       20.1, 23.2, 22.3, 24.8, 28.5, 37.3, 27.9, 23.9, 21.7, 28.6, 27.1,\n       20.3, 22.5, 29. , 24.8, 22. , 26.4, 33.1, 36.1, 28.4, 33.4, 28.2,\n       22.8, 20.3, 16.1, 22.1, 19.4, 21.6, 23.8, 16.2, 17.8, 19.8, 23.1,\n       21. , 23.8, 23.1, 20.4, 18.5, 25. , 24.6, 23. , 22.2, 19.3, 22.6,\n       19.8, 17.1, 19.4, 22.2, 20.7, 21.1, 19.5, 18.5, 20.6, 19. , 18.7,\n       32.7, 16.5, 23.9, 31.2, 17.5, 17.2, 23.1, 24.5, 26.6, 22.9, 24.1,\n       18.6, 30.1, 18.2, 20.6, 17.8, 21.7, 22.7, 22.6, 25. , 19.9, 20.8,\n       16.8, 21.9, 27.5, 21.9, 23.1, 50. , 50. , 50. , 50. , 50. , 13.8,\n       13.8, 15. , 13.9, 13.3, 13.1, 10.2, 10.4, 10.9, 11.3, 12.3,  8.8,\n        7.2, 10.5,  7.4, 10.2, 11.5, 15.1, 23.2,  9.7, 13.8, 12.7, 13.1,\n       12.5,  8.5,  5. ,  6.3,  5.6,  7.2, 12.1,  8.3,  8.5,  5. , 11.9,\n       27.9, 17.2, 27.5, 15. , 17.2, 17.9, 16.3,  7. ,  7.2,  7.5, 10.4,\n        8.8,  8.4, 16.7, 14.2, 20.8, 13.4, 11.7,  8.3, 10.2, 10.9, 11. ,\n        9.5, 14.5, 14.1, 16.1, 14.3, 11.7, 13.4,  9.6,  8.7,  8.4, 12.8,\n       10.5, 17.1, 18.4, 15.4, 10.8, 11.8, 14.9, 12.6, 14.1, 13. , 13.4,\n       15.2, 16.1, 17.8, 14.9, 14.1, 12.7, 13.5, 14.9, 20. , 16.4, 17.7,\n       19.5, 20.2, 21.4, 19.9, 19. , 19.1, 19.1, 20.1, 19.9, 19.6, 23.2,\n       29.8, 13.8, 13.3, 16.7, 12. , 14.6, 21.4, 23. , 23.7, 25. , 21.8,\n       20.6, 21.2, 19.1, 20.6, 15.2,  7. ,  8.1, 13.6, 20.1, 21.8, 24.5,\n       23.1, 19.7, 18.3, 21.2, 17.5, 16.8, 22.4, 20.6, 23.9, 22. , 11.9])"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}